package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.domain.Menu_management;
import com.itheima.domain.Permission_management;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface Permission_managementDao {
    @Select("select * from t_permission")
    List<Permission_management> findAll();
    @Select("select * from t_permission where id = #{userId}")
    Permission_management findById(Integer userId);
    @Update({"update user set id=#{id},name=#{name},keyword=#{keyword},description=#{description},creativeTime=#{creativetime},isEnable=#{isenable},path=#{path}"})
    void updatePermission(Permission_management permission);
    @Insert("insert into t_permission values(null,#{name},#{creativeTime},#{isEnable},#{path})")
    void save(Permission_management permission_management);
    @Delete("delete from t_permission where id = #{id}")
    void deleteById(Integer id);
    @Update({"update `t_permission`  set name=#{name},creativeTime=#{creativeTime},isEnable=#{isEnable},path=#{path}  where id=#{id}"})
    void edit(Permission_management permission_management);


    Page<Permission_management> selectByCondition(String queryString);

    @Select("<script>" +
            "select * from t_permission\n" +
            "<if test=\"value != null and value.length > 0\">\n" +
            "where code like concat(concat('%',#{value}),'%') or name like concat(concat('%',#{value}),'%') or id like concat(concat('%',#{value}),'%')\n" +
            "</if>" +
            "</script>")
    List<Permission_management> EstimateFindAll();
}
